﻿// //   Copyright 2007-2011 Comdiv (F. Sadykov) - http://code.google.com/u/fagim.sadykov/
// //   Supported by Media Technology LTD 
// //    
// //   Licensed under the Apache License, Version 2.0 (the "License");
// //   you may not use this file except in compliance with the License.
// //   You may obtain a copy of the License at
// //    
// //        http://www.apache.org/licenses/LICENSE-2.0
// //    
// //   Unless required by applicable law or agreed to in writing, software
// //   distributed under the License is distributed on an "AS IS" BASIS,
// //   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// //   See the License for the specific language governing permissions and
// //   limitations under the License.
// //   
// //   MODIFICATIONS HAVE BEEN MADE TO THIS FILE

using System;
using System.Collections.Generic;
using Comdiv.QWeb.Logging;

namespace Comdiv.QWeb.Events {
	public class QWebEvent<TData, TResult> : IQWebEvent<TData, TResult>
		where TData : IQWebEventData, new()
		where TResult : IQWebEventResult, new() {
		private readonly IList<Exception> _errors = new List<Exception>();
		private TData _data;
		private ILogListener _log;
		private TResult _result;
		private QWebContext context;

		#region IQWebEvent<TData,TResult> Members

		public void SetContext(QWebContext context) {
			this.context = context;
			_data = new TData();
			_data.Build(context);
			_result = new TResult();
		}

		public void SetLog(ILogListener listener) {
			_log = listener;
		}

		public ILogListener Log {
			get { return _log; }
		}

		public QWebContext Context {
			get { return context; }
		}

		public IList<Exception> Errors {
			get { return _errors; }
		}

		public TData Data {
			get { return _data; }
		}

		public TResult Result {
			get { return _result; }
		}

		#endregion
		}
}